package com.example.demo.zaqizabatest.多线程相关;

/**
 * @author lys4134
 * @ClassName CreateThread1
 * @Date 2022/03/14 16:40:34
 * @Description CreateThread1
 * @Version 1.0
 **/
public class CreateThread1 extends Thread {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }


    public static int getMaxValue (int[] nums, int[] values) {
        int dp[] = new int[nums.length + 1];
        int left = 0;
        int right = nums.length - 1;
        dp[0] = 0;
        int i = 1;
        for (int value : values) {
            if(left > right){
                return dp[nums.length];
            }
            if(nums[left] > nums[right]){
                dp[i] = dp[i - 1] + nums[left] * value;
                left++;
            } else{
                dp[i] = dp[i - 1] + nums[right] * value;
                right--;
            }
            i++;
        }
        return dp[nums.length];
    }

    public static void main(String[] args) {
        int[] a = new int[]{1, 3, 5, 2, 4};
        int[] b = new int[]{1,2,3,4,5};
        int maxValue = getMaxValue(a, b);
        System.out.println(maxValue);
    }



//    public static void main(String[] args) {
//        CreateThread1 createThread1 = new CreateThread1();
//        createThread1.setName("aaaaaaa");
//        createThread1.start();
//        System.out.println(Thread.currentThread().getName());
//    }
}
